<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input class="weather" type="text"><button class="btn">点击按钮查询是否带伞</button>
    <script>
        var btn=document.getElementsByClassName("btn")[0];
        console.log(btn);
        var weather=document.getElementsByClassName("weather")[0];
        btn.onclick=function(){
            var res=weather.value;
            if(res=="下雨了"){
                alert("需要带伞")
            }else{
                alert("不需要带伞")
            }
        }
    </script>
</body>
</html>